package com.example.lending.Model.Dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;


import com.example.lending.Model.Borrow;

import java.util.List;

@Dao
public interface BorrowDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertBorrow(Borrow... borrows);

    @Update(onConflict = OnConflictStrategy.REPLACE)
    void updataBorrow(Borrow... borrows);

    @Delete
    void deleteBorrow(Borrow... borrows);

    @Query("delete from borrow")
    void deleteAllBorrow();

    @Query("select * from borrow order by id desc")
    LiveData<List<Borrow>> getAllBorrowLive();

    @Query("select * from Borrow where name like :pattern order by id desc")
    LiveData<List<Borrow>>findBorrowWithPattern(String pattern);
}
